var appInfoData = {
  loading: false,
  urls: {
    queryAppInfo: '/api/queryAppInfo'
  },
  pageConfig: {
    width: {label: '120px'},
    dialog: {
      visible: false
    }
  },
  pageData: null,
  areaList: null
}

var methods = {
  init () {
    this.$http.get(this.urls.queryAppInfo).then(response => {
      this.pageData = response.data
      this.areaList = response.data.areaList
    })
  },
  closeFavoriteDialog () {
    this.pageConfig.dialog.visible = false
  },
  openFavoriteDialog () {
    this.pageConfig.dialog.visible = true
  },
  addFavorite (areaIndex, fieldIndex) {
    this.areaList[areaIndex].fieldList[fieldIndex].important = true
    // todo 更新数据库数据
    console.log('todo 更新数据库数据 - 添加收藏-{}', this.areaList[areaIndex].fieldList[fieldIndex].modelName)
  },
  removeFavorite (areaIndex, fieldIndex) {
    this.areaList[areaIndex].fieldList[fieldIndex].important = false
    // todo 更新数据库数据
    console.log('todo 更新数据库数据 - 取消收藏-{}', this.areaList[areaIndex].fieldList[fieldIndex].modelName)
  }
}

export {
  appInfoData,
  methods
}
